package nju.bean.meeting.meetingManagement;

import static org.junit.Assert.*;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import nju.bean.meeting.data.Meeting;
import nju.bean.meeting.data.User;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class MeetingManagerTest01 {
	static MeetingManager meetMag;
	static Meeting meeting;
	static User raiseUser;
	static User attendUser;
	
	
	
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		meeting = new Meeting("SCS","17222136",5,new User());
		raiseUser = new User("software","1","male","Microsoft","PM","123@123.com");
		attendUser = new User("nju","2","female","IBM","tester","163@163.com");
		int [] port = {30003,30004,30005,30006,30007,30008,30009,30010,30011};
		meetMag = new MeetingManager(meeting,port);
		MainMeetingManager.getInstance();
	}
 
	@After
	public void tearDown() throws Exception {
		
	}


	@Test
	public void testAddMeeting() {
		assertNotNull(meetMag.addMeeting(attendUser.getUserName()));
//		fail("unable to test this method without the support of DB");
	}

	@Test
	public void testLeaveMeeting() {
//		boolean Ok=false;
//		try {
//			Ok = meetMag.leaveMeeting(raiseUser.getUserName());
//		} catch (MeetingOverException e) {
//			// TODO Auto-generated catch block
//			System.out.println("Exception throws when leaving meeting.");
//			e.printStackTrace();
//		}
//		assertTrue(Ok);
		fail("error!");
	}

	@Test
	public void testEndMeeting() {
		fail("Not yet implemented");
	}

	@Test
	public void testSendMessage() {
		fail("Not yet implemented");
	}

	@Test
	public void testSendComment() {
		fail("Not yet implemented");
	}

	@Test
	public void testSendDiagram() {
		fail("Not yet implemented");
	}

	@Test
	public void testAllowEndMeeting() {		
		fail("Can't test state of enToken");
	}

	@Test
	public void testGetMeeting() {
		assertNotNull(meetMag.getMeeting());
	}

	@Test
	public void testGetDiagramIndex() {
		assertNotNull(meetMag.getDiagramIndex());
	}

	@Test
	public void testSetDiagramIndex() {
		meetMag.setDiagramIndex(14);
		assertEquals(14, meetMag.getDiagramIndex());
	}

	@Test
	public void testGetDiagramManager() {
		assertNotNull(meetMag.getDiagramManager());
	}

	@Test
	public void testGetUserList() {
		assertNotNull(meetMag.getUserList());
	}

	@Test
	public void testGetCounter() {
		assertNotNull(meetMag.getCounter());
	}

	@Test
	public void testGetPresentColorList() {
		assertNotNull(meetMag.getPresentColorList());
	}

	@Test
	public void testGetColor() {
		assertNotNull(meetMag.getColor(raiseUser.getUserName()));
	}

	@Test
	public void testGetPort() {
		assertNotNull(meetMag.getPort());
	}

	@Test
	public void testGetNumOfUser() {
		assertEquals(1,meetMag.getNumOfUser());
	}

//	@Test
//	public void testDealPort(){
//		try {
//			Method method = meetMag.getClass().getDeclaredMethod("dealPort");
//			method.setAccessible(true);
//			method.invoke(meetMag);
//		} catch (NoSuchMethodException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (SecurityException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (IllegalArgumentException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (InvocationTargetException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//	}
}
